﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using GrewalCRM.Entities;

namespace GrewalCRM.Entities
{
  public class DealersMaster : BaseEntitiesGrewalCRM
  {
    #region Members   
    private string dealerName;
    private string counter;    
    private string address;
    private string contactNo;
    private decimal? dealerCommission;   
    #endregion

    #region Constructors
    /// <summary>
    /// Create a new instance using the default constructor
    /// </summary>
    public DealersMaster():base()
    {      
    }

    /// <summary> 
    /// Create a new object using the minimum required information (all not-null fields except 
    /// auto-generated primary keys). 
    /// </summary> 
    public DealersMaster(string dealerName, string counter, string address, UserCRM lastModifiedUser)
      : base(lastModifiedUser)
    {    
      this.dealerName = dealerName;
      this.counter = counter;
      this.address = address;      
    }

    /// <summary> 
    /// Create a new object by specifying all fields (except the auto-generated primary key field). 
    /// </summary> 
    public DealersMaster(string dealerName, string counter, string address, string contactNo, decimal? dealerCommission, UserCRM lastModifiedUser)
      : base(lastModifiedUser)
    {
      
      this.dealerName = dealerName;
      this.counter = counter;
      this.address = address;
      this.contactNo = contactNo; 
      this.dealerCommission= dealerCommission; 
    }

    /// <summary> 
    /// Create an object from an existing row of data with only ID feild 
    /// </summary> 
    public DealersMaster(int dealerID)
      : base(dealerID, null, null)
    {
      
    }

    /// <summary> 
    /// Create an object from an existing row of data. This will be used by Gentle to 
    /// construct objects from retrieved rows. 
    /// </summary> 
    public DealersMaster(int dealerID, string dealerName, string counter, string address, string contactNo, decimal? dealerCommission,  bool isActive, UserCRM lastModifiedUser, DateTime? lastModifiedDateTime)
      : base(dealerID, isActive, lastModifiedUser, lastModifiedDateTime)
    {      
      this.dealerName = dealerName;
      this.counter = counter;
      this.address = address;
      this.contactNo = contactNo;
      this.dealerCommission = dealerCommission; 
    }
    #endregion

    #region Public Properties    
    /// <summary>
    /// Property relating to database column DealerName
    /// </summary>   
    public string DealerName
    {
      get { return dealerName != null ? dealerName.TrimEnd() : string.Empty; }
      set { IsChanged |= dealerName != value; dealerName = value; }
    }

    /// <summary>
    /// Property relating to database column Counter
    /// </summary>    
    public string Counter
    {
      get { return counter != null ? counter.TrimEnd() : string.Empty; }
      set { IsChanged |= counter != value; counter = value; }
    }

    /// <summary>
    /// Property relating to database column Counter
    /// </summary>    
    public string DealerCounterName
    {
      get { return dealerName + "-" + counter; }     
    }

    /// <summary>
    /// Property relating to database column Address
    /// </summary>    
    public string Address
    {
      get { return address != null ? address.TrimEnd() : string.Empty; }
      set { IsChanged |= address != value; address = value; }
    }

    /// <summary>
    /// Property relating to database column ContactNo
    /// </summary>    
    public string ContactNo
    {
      get { return contactNo != null ? contactNo.TrimEnd() : string.Empty; }
      set { IsChanged |= contactNo != value; contactNo = value; }
    }

    /// <summary>
    /// Property relating to database column DealerCommission
    /// </summary>    
    public decimal? DealerCommission
    {
      get { return dealerCommission; }
      set { IsChanged |= dealerCommission != value; dealerCommission = value; }
    }
    #endregion
  }
}
